#include <stdio.h>

typedef struct BNode{
    BNode * lchild;
    BNode * rchild;
    int data;
}BNode,*BTree;

int leafnum = 0;

void getLeafNum1(BTree T){
    if (T != NULL)
    {
        if (T->lchild == NULL && T->rchild == NULL)
        {
            leafnum++;
        }
        getLeafNum(T->lchild);
        getLeafNum(T->rchild);
    }
}

int getLeafNum2(BTree T){
    if(!T)
        return 0;
    if(T->lchild == NULL && T->rchild == NULL)
        return 1;
    return getLeafNum2(T->lchild) + getLeafNum2(T->rchild);
}